#include "ahutimer.h"
#include "ahudata.h"
#include "ahufsm.h"

/* 检查风机开状态 */
void ahu_to_sf_onwait(void *arg)
{
    ES_PRT_INFO("AHU: timer 'TMR_SF_ONWAIT' timeout, check dev_id[%s] sf on state \n", ((ahu_dev_t *)arg)->device_id);

    data_type_u val;
    enum error_code err;

    /* 读取风机状态点位 */
    err = read_rp_byname((ahu_dev_t *)arg, "SF-S", &val);

    /* 风机状态点位存在，就判断是否为true */
    if(err == Success){
        if(val.b == true){
            ES_PRT_INFO("dev_id[%s], SF-S exist, send EV_SF_ON \n", ((ahu_dev_t *)arg)->device_id);
            send_event((ahu_dev_t *)arg, EV_SF_ON);
        }

    /* 风机状态点位不存在，就默认风机已经打开，直接发送事件 */
    }else if(err == ErrNoExist){
        ES_PRT_INFO("dev_id[%s], SF-S unexist, send EV_SF_ON \n", ((ahu_dev_t *)arg)->device_id);
        send_event((ahu_dev_t *)arg, EV_SF_ON);
    }

}